<?php

namespace app\admin\controller;

use app\BaseController;
use app\common\model\auth\AuthAdminModel;

class Login extends BaseController
{
    /**
     * 登录
     */
    public function login()
    {
        $params = request()->only(['mobile', 'password']);
        $this->validate($params, [
            'mobile|手机' => 'require',
            'password|密码' => 'require'
        ]);


        $authAdminModel = new AuthAdminModel;
        $res = $authAdminModel->login($params['mobile'], $params['password']);
        if (!$res) {
            return response_error($authAdminModel->getError());
        }

        return response_success('登录成功', $res);
    }

}